#-*-coding:utf-8-*-
# 时间:2019/8/29
# 作者:zfh
# 导入
from openpyxl import load_workbook
import sys,os
import readConfig
from Log import MyLog

# 打开一个工作薄
# wb = load_workbook('file_name.xlsx')

proDir = readConfig.proDir

excelDir = os.path.join(proDir, 'testCase', 'testCase.xlsx')
# MyLog.log = Log()
log = MyLog.get_log()
logger = log.logger


def readexcel(sheet_name):
    L = []
    try:
        # 打开excel文件
        wb = load_workbook(excelDir)
        logger.info('读取excel文件成功')
        # 读取excel表的内容
        # sheet = wb[sheet_name] 据说目前改成这种了
        sheet = wb.get_sheet_by_name(sheet_name)
        # 读取整行内容
        for row in sheet.rows:
            # 将整行内容，分割成list
            line = [col.value for col in row]
            # 如果不是为case_name，就加入到列表中
            if line[0] != 'case_name':
                L.append(line)
    except:
        logger.info('----读取excel文件失败----')
    return L

